function varargout = vslice_vel(varargin)
% VSLICE_VEL M-file for vslice_vel.fig
%      VSLICE_VEL, by itself, creates a new VSLICE_VEL or raises the existing
%      singleton*.
%
%      H = VSLICE_VEL returns the handle to a new VSLICE_VEL or the handle to
%      the existing singleton*.
%
%      VSLICE_VEL('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in VSLICE_VEL.M with the given input arguments.
%
%      VSLICE_VEL('Property','Value',...) creates a new VSLICE_VEL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before vslice_vel_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to vslice_vel_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help vslice_vel

% Last Modified by GUIDE v2.5 04-May-2006 13:53:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @vslice_vel_OpeningFcn, ...
                   'gui_OutputFcn',  @vslice_vel_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before vslice_vel is made visible.
function vslice_vel_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to vslice_vel (see VARARGIN)

% Choose default command line output for vslice_vel
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes vslice_vel wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = vslice_vel_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --------------------------------------------------------------------
function vslice_velocity_export_to_ws_menu_Callback(hObject, eventdata, handles)
% hObject    handle to vslice_velocity_export_to_ws_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Export the vslice data into the base workspace.

	vdata = guidata ( hObject );
	gdata = guidata ( vdata.parent );
	assignin ( 'base', 'x', gdata.vslice_vel_data.vx );
	assignin ( 'base', 'z', gdata.vslice_vel_data.vz );
	assignin ( 'base', 'ut', real(gdata.vslice_vel_data.vdata) );
	assignin ( 'base', 'un', imag(gdata.vslice_vel_data.vdata) );
	assignin ( 'base', 'cpx', gdata.vslice_vel_data.control_pt_x );
	assignin ( 'base', 'cpy', gdata.vslice_vel_data.control_pt_y );



% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function vslice_menu_Callback(hObject, eventdata, handles)
% hObject    handle to vslice_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

	vdata = guidata ( hObject );

	options.use_vslice_vel_line = 1;
	options.get_new_line = 0;
	options.retrieve_new_data = 1;
	rslice_vslice_redraw( vdata.parent, options )

	return

% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function cmin_edit_Callback(hObject, eventdata, handles)
% hObject    handle to cmin_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cmin_edit as text
%        str2double(get(hObject,'String')) returns contents of cmin_edit as a double

	vdata = guidata ( hObject );

	options.use_vslice_vel_line = 1;
	options.get_new_line = 0;
	options.retrieve_new_data = 0;
	rslice_vslice_velocity_redraw( vdata.parent, options )
	return



% --- Executes during object creation, after setting all properties.
function cmin_edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cmin_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function cmax_edit_Callback(hObject, eventdata, handles)
% hObject    handle to cmax_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cmax_edit as text
%        str2double(get(hObject,'String')) returns contents of cmax_edit as a double


	vdata = guidata ( hObject );

	options.use_vslice_vel_line = 1;
	options.get_new_line = 0;
	options.retrieve_new_data = 0;
	rslice_vslice_velocity_redraw( vdata.parent, options )
	return



% --- Executes during object creation, after setting all properties.
function cmax_edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cmax_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --------------------------------------------------------------------
function Print_vslice_vel_tag_Callback(hObject, eventdata, handles)
% hObject    handle to Print_vslice_vel_tag (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
	
	printdlg;


% --------------------------------------------------------------------
function Vslice_vel_hide_tag_Callback(hObject, eventdata, handles)
% hObject    handle to Vslice_vel_hide_tag (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


	vdata = guidata ( hObject );
	gdata = guidata ( vdata.parent );

	%
	% Is the vslice figure visible?  If so, then issue a redraw.
	vis = get ( gdata.vslice_vel_figure, 'Visible' );
	if strcmp ( vis, 'on' )
		set ( gdata.vslice_vel_figure, 'Visible', 'off' );
	end

	return
